library("dplyr")
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library("tidyverse")
## ── Attaching packages ───────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0     ✔ readr   1.1.1
## ✔ tibble  2.0.1     ✔ purrr   0.3.0
## ✔ tidyr   0.8.2     ✔ stringr 1.4.0
## ✔ ggplot2 3.1.0     ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library("rio")
library("here")
## here() starts at /Users/pssst/Documents/UO/Terms/Winter 2019/R/viz
library("forcats")
library("fivethirtyeight")
library("wesanderson")
library("ggplot2")
library("gdata")
## gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
## 
## gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
## 
## Attaching package: 'gdata'
## The following object is masked from 'package:purrr':
## 
##     keep
## The following objects are masked from 'package:dplyr':
## 
##     combine, first, last
## The following object is masked from 'package:stats':
## 
##     nobs
## The following object is masked from 'package:utils':
## 
##     object.size
## The following object is masked from 'package:base':
## 
##     startsWith
library("viridis")
## Loading required package: viridisLite
library("colorblindr")
## Loading required package: colorspace
library("stringr")
library("tidytext")
library("kableExtra")
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library("formattable")
library("flextable")
## 
## Attaching package: 'flextable'
## The following object is masked from 'package:formattable':
## 
##     style
## The following object is masked from 'package:kableExtra':
## 
##     as_image
## The following object is masked from 'package:purrr':
## 
##     compose
knitr::opts_chunk$set(warning = FALSE,
                      message = FALSE,
                      error = TRUE,
                      fig.width = 6.5,
                      fig.height = 8
                      )
theme_set(theme_minimal(base_size = 8))
# Resize plot
knitr::opts_chunk$set(fig.width=12, fig.height=8) 
SKY <- import(here("data", "survey.xlsx"), setclass = "tbl_df") 

str(SKY)
## Classes 'tbl_df', 'tbl' and 'data.frame':    21 obs. of  18 variables:
##  $ Name                     : chr  "FB" "SH" "DD" "NP" ...
##  $ Gender                   : chr  "Male" "Female" "Female" "Female" ...
##  $ Category                 : chr  "Faculty/Staff" "Community member" "Community member" "Graduate" ...
##  $ Class                    : chr  NA NA NA NA ...
##  $ Experience               : chr  "I thought it was positive and powerful." "It was very beautiful. It felt like truth." "Fantastic growth experience" "Wonderful! There were physically challenging moments while sitting for Sudarshan Kriya but I benefited a lot & "| __truncated__ ...
##  $ Say                      : chr  "It's a connection that connects" "I would say it is very much worthwhile" "Do it! Jump in!" "Come with an open mind, leave with an open heart." ...
##  $ Recommend-10             : num  9 10 10 8 10 10 10 9 10 10 ...
##  $ energy                   : num  5 5 5 5 4 5 5 5 NA 5 ...
##  $ clarity_mind             : num  5 5 5 5 4 5 5 5 NA 5 ...
##  $ multiple_responsibilities: num  4 5 5 5 5 5 5 5 NA 5 ...
##  $ connect_to_myself        : num  5 5 5 5 4 5 5 5 NA 5 ...
##  $ stay_focused             : num  5 5 5 5 5 5 5 5 NA 5 ...
##  $ remain_calm              : num  5 5 5 5 3 5 5 5 NA 5 ...
##  $ gain_resilience          : num  5 5 5 5 4 5 5 5 NA 5 ...
##  $ broader_perspectives     : num  5 5 5 5 5 5 5 5 NA 4 ...
##  $ connect_with_others      : num  5 5 5 5 5 5 5 5 NA 4 ...
##  $ good_investment_of_time  : num  5 5 5 4 5 5 5 5 5 5 ...
##  $ Recommend                : num  4 5 5 4 5 5 5 5 5 5 ...
#original
#Fig1.1
ggplot(SKY, aes(x = Category)) +
  geom_histogram(stat = "Count",
                 fill = "#56B4E9",
                 color = "white",
                 alpha = 0.7) +
   theme_minimal(base_size = 15)

#original
#Fig1.2
SKY
## # A tibble: 21 x 18
##    Name  Gender Category Class Experience Say   `Recommend-10` energy
##    <chr> <chr>  <chr>    <chr> <chr>      <chr>          <dbl>  <dbl>
##  1 FB    Male   Faculty… <NA>  I thought… It's…              9      5
##  2 SH    Female Communi… <NA>  It was ve… I wo…             10      5
##  3 DD    Female Communi… <NA>  Fantastic… Do i…             10      5
##  4 NP    Female Graduate <NA>  Wonderful… Come…              8      5
##  5 CD2   Female Post-ba… <NA>  I had a w… I wo…             10      4
##  6 HL    Female Graduate <NA>  I feel em… It w…             10      5
##  7 AK    Female Graduate <NA>  Very posi… It's…             10      5
##  8 YC    Female Graduate <NA>  Great! I … <NA>               9      5
##  9 SW    Female Graduate <NA>  So positi… Abso…             10     NA
## 10 AR    Male   Graduate <NA>  It was en… How …             10      5
## # … with 11 more rows, and 10 more variables: clarity_mind <dbl>,
## #   multiple_responsibilities <dbl>, connect_to_myself <dbl>,
## #   stay_focused <dbl>, remain_calm <dbl>, gain_resilience <dbl>,
## #   broader_perspectives <dbl>, connect_with_others <dbl>,
## #   good_investment_of_time <dbl>, Recommend <dbl>
SKY %>% 
  mutate(Category = factor(Category, 
                           levels = c("Graduate",
                                      "Community member", 
                                      "Faculty/Staff",
                                      "Undergrad",
                                      "Post-bach"))) %>% 

ggplot(aes(x = Category)) +
  geom_histogram(stat = "count",
                 color = "white",
                 alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1)) +
  scale_fill_OkabeIto() +
  coord_flip() +
  labs(x = "Category",
       y = "Count",
       title = "Where are the participants from?") +
    theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank"))

...............
## Error in eval(expr, envir, enclos): object '...............' not found
#updated
#Fig1.3
SKY %>% 
  count(Category) %>% 
  ggplot(aes(x = fct_reorder(Category, n), n)) +
  geom_col(aes(fill = Category),
           color = "white",
           alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1),
                     limits = c(0, 10.25)) +
  scale_fill_OkabeIto() +
  coord_flip(expand = FALSE) +
  labs(x = "Category",
       y = "Count",
       title = "Where are the participants from?") +
  theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  guides(fill = "none")

#reviewer -updated
OH0 <- SKY %>% 
  group_by(Category, Gender) %>% 
  summarise(n=n()) 
  
ggplot(OH0, aes(x = fct_reorder(Category, n), n)) +
  geom_col(aes(fill = Gender),
           color = "white",
           alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1),
                     limits = c(0, 10.25)) +
  scale_fill_OkabeIto() +
  coord_flip(expand = FALSE) +
  labs(x = "",
       y = "Number of participants",
       title = "Here is the distribution of the participants") +
  theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  guides(fill = "none")+
  geom_text(data=OH0[1,], aes(label=Gender), hjust=0)+
  geom_text(data=OH0[2,], aes(label=Gender), hjust =2)

library(ggridges)

#original
#Fig 2.1
ggplot(SKY, x = 0:5, aes(Recommend, Category)) +
   ggridges::geom_density_ridges(color = "white",
                                alpha = 0.4) +
  scale_color_OkabeIto() +
    labs(x = "Strongly Disagree - Strongly Agree",
       y = "Category",
       title = "I would recommend this training to my peers as they would benefit from it")  +
  theme_minimal(base_size = 15)

...............
## Error in eval(expr, envir, enclos): object '...............' not found
#updated
#Fig 2.2
ggplot(SKY, aes(Recommend)) +
  geom_dotplot(aes(fill = Category), 
               stackgroups = TRUE,
               binwidth = 0.3) +
  scale_fill_OkabeIto() +
  scale_x_continuous(breaks = 0:6, limits = c(0, 6),
                     labels=c("0" = "", 
                              "1" = "Strongly Disagree",
                              "2" = "Disagree", 
                              "3" = "Neutral",
                              "4" = "Agree", 
                              "5" = "Strongly Agree",
                              "6" = "")) +
  scale_y_continuous(labels=c("0.00" = "0", 
                              "0.25" = "6",
                              "0.50" = "12", 
                              "0.75" = "18",
                              "1.00" = "24")) +
   coord_flip() +
   coord_flip(expand = FALSE) +
   theme_minimal(base_size = 15) +
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  labs(x = NULL, 
       y = NULL, 
       title = "I would recommend this training to my peers as they would benefit",
       subtitle = "N = 21")+
  labs(y = "Number of Participants")

?scale_fill_manual
#updated2
ggplot(SKY, aes(Recommend)) +
  geom_dotplot(aes(fill = Category), 
               stackgroups = TRUE,
               binwidth = 0.31) +
  scale_fill_OkabeIto(name = "") +
  scale_x_continuous(breaks = 0:6, limits = c(0, 6),
                     labels=c("0" = "", 
                              "1" = "Strongly Disagree",
                              "2" = "Disagree", 
                              "3" = "Neutral",
                              "4" = "Agree", 
                              "5" = "Strongly Agree",
                              "6" = "")) +
  scale_y_continuous(labels=c("0.00" = "0", 
                              "0.25" = "6",
                              "0.50" = "12", 
                              "0.75" = "18",
                              "1.00" = "24")) +
   coord_flip() +
   coord_flip(expand = FALSE) +
   theme_minimal(base_size = 15) +
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  labs(x = NULL, 
       y = NULL, 
       title = "Here is how the participants feel about recommending this Retreat to their peers",
       subtitle = "N = 21")+
  labs(y = "Number of Participants")

#original
Fig3.1 <- ggplot(SKY, aes(x = Name, y = energy)) +
   geom_point() +
  coord_flip() +
  labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my energy levels") +
    theme_minimal(base_size = 15)
Fig3.1 + ylim(0, 5)

Fig3.2 <- ggplot(SKY, aes(x = Name, y = clarity_mind)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has enhanced my clarity of mind") +
    theme_minimal(base_size = 15)
Fig3.2 + ylim(0, 5)

Fig3.3 <- ggplot(SKY, aes(x = Name, y = multiple_responsibilities)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my ability to manage multiple responsibilities") +
    theme_minimal(base_size = 15)
Fig3.3 + ylim(0, 5)

Fig3.4 <- ggplot(SKY, aes(x = Name, y = connect_to_myself)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has enhanced my ability to connect to myself") +
    theme_minimal(base_size = 15)
Fig3.4 + ylim(0, 5)

Fig3.5 <- ggplot(SKY, aes(x = Name, y = stay_focused)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my ability to stay focused on the task at hand") +
    theme_minimal(base_size = 15)
Fig3.5 + ylim(0, 5)

Fig3.6 <- ggplot(SKY, aes(x = Name, y = remain_calm)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has improved my ability to remain calm in difficult situations") +
    theme_minimal(base_size = 15)
Fig3.6 + ylim(0, 5)

Fig3.7 <- ggplot(SKY, aes(x = Name, y = gain_resilience)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my ability to gain resilience")+
    theme_minimal(base_size = 15) 
Fig3.7 + ylim(0, 5)

Fig3.8 <- ggplot(SKY, aes(x = Name, y = broader_perspectives)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my ability to gain broader perspectives when facing challenging situations") +
    theme_minimal(base_size = 15)
Fig3.8 + ylim(0, 5)

Fig3.9 <- ggplot(SKY, aes(x = Name, y = connect_with_others)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat has increased my ability to connect with others") +
    theme_minimal(base_size = 15)
Fig3.9 + ylim(0, 5)

Fig3.10 <-ggplot(SKY, aes(x = Name, y = good_investment_of_time)) +
  geom_point() +
  coord_flip() +
    labs(x = "Participant",
       y = "Strongly Disagree - Strongly Agree",
       title = "The Retreat is a good investment of time") +
    theme_minimal(base_size = 15)
Fig3.10 + ylim(0, 5)

...............
## Error in eval(expr, envir, enclos): object '...............' not found
#updated
SKY %>%
  count(energy) %>%
  mutate(prop = 100*n/sum(n-1)) 
## # A tibble: 4 x 3
##   energy     n  prop
##    <dbl> <int> <dbl>
## 1      3     1  5.88
## 2      4     3 17.6 
## 3      5    16 94.1 
## 4     NA     1  5.88
SKY %>%
  count(clarity_mind) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   clarity_mind     n  prop
##          <dbl> <int> <dbl>
## 1            4     3 16.7 
## 2            5    17 94.4 
## 3           NA     1  5.56
SKY %>%
  count(multiple_responsibilities) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   multiple_responsibilities     n  prop
##                       <dbl> <int> <dbl>
## 1                         4     5 27.8 
## 2                         5    15 83.3 
## 3                        NA     1  5.56
SKY %>%
  count(connect_to_myself) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   connect_to_myself     n  prop
##               <dbl> <int> <dbl>
## 1                 4     4 22.2 
## 2                 5    16 88.9 
## 3                NA     1  5.56
SKY %>%
  count(stay_focused) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   stay_focused     n  prop
##          <dbl> <int> <dbl>
## 1            4     3 16.7 
## 2            5    17 94.4 
## 3           NA     1  5.56
SKY %>%
  count(remain_calm) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 4 x 3
##   remain_calm     n  prop
##         <dbl> <int> <dbl>
## 1           3     1  5.88
## 2           4     3 17.6 
## 3           5    16 94.1 
## 4          NA     1  5.88
SKY %>%
  count(gain_resilience) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   gain_resilience     n  prop
##             <dbl> <int> <dbl>
## 1               4     4 22.2 
## 2               5    16 88.9 
## 3              NA     1  5.56
SKY %>%
  count(broader_perspectives) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   broader_perspectives     n  prop
##                  <dbl> <int> <dbl>
## 1                    4     4 22.2 
## 2                    5    16 88.9 
## 3                   NA     1  5.56
SKY %>%
  count(connect_with_others) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   connect_with_others     n  prop
##                 <dbl> <int> <dbl>
## 1                   4     3 16.7 
## 2                   5    17 94.4 
## 3                  NA     1  5.56
SKY2 <- import(here("data", "SKY2.xlsx"), setclass = "tbl_df") 

SKY2 %>% 
  kable() %>% 
   kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive", full_width = NULL, position = "left")) %>% 
  column_spec(6:6, bold = T, color = "#3A9E23", background = "#F8F668") %>%
   footnote(general = "The participants were asked to rate how the techniques taught in the SKY Happiness Retreat have the ability to impact different areas.",
            number = c("Numbers are in percentage"))
:) Strongly Disagree Disagree Neutral Agree Strongly Agree
Increase my energy levels 0 0 5 15 80
Enhance my clarity of mind 0 0 0 15 85
Increase my ability to manage multiple responsibilities 0 0 0 25 75
Enhance my ability to connect to myself 0 0 0 20 80
Increase my ability to stay focused on the task at hand 0 0 5 15 80
Improve my ability to remain calm in difficult situations 0 0 5 15 80
Increase my ability to gain resilience 0 0 0 20 80
Increase my ability to gain broader perspectives when facing challenging situations 0 0 0 20 80
Increase my ability to connect with others 0 0 0 15 85
The training was good investment of time 0 0 0 14 86
Note:
The participants were asked to rate how the techniques taught in the SKY Happiness Retreat have the ability to impact different areas.
1 Numbers are in percentage
#updated 
SKY %>%
  count(energy) %>%
  mutate(prop = 100*n/sum(n-1)) 
## # A tibble: 4 x 3
##   energy     n  prop
##    <dbl> <int> <dbl>
## 1      3     1  5.88
## 2      4     3 17.6 
## 3      5    16 94.1 
## 4     NA     1  5.88
SKY %>%
  count(clarity_mind) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   clarity_mind     n  prop
##          <dbl> <int> <dbl>
## 1            4     3 16.7 
## 2            5    17 94.4 
## 3           NA     1  5.56
SKY %>%
  count(multiple_responsibilities) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   multiple_responsibilities     n  prop
##                       <dbl> <int> <dbl>
## 1                         4     5 27.8 
## 2                         5    15 83.3 
## 3                        NA     1  5.56
SKY %>%
  count(connect_to_myself) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   connect_to_myself     n  prop
##               <dbl> <int> <dbl>
## 1                 4     4 22.2 
## 2                 5    16 88.9 
## 3                NA     1  5.56
SKY %>%
  count(stay_focused) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   stay_focused     n  prop
##          <dbl> <int> <dbl>
## 1            4     3 16.7 
## 2            5    17 94.4 
## 3           NA     1  5.56
SKY %>%
  count(remain_calm) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 4 x 3
##   remain_calm     n  prop
##         <dbl> <int> <dbl>
## 1           3     1  5.88
## 2           4     3 17.6 
## 3           5    16 94.1 
## 4          NA     1  5.88
SKY %>%
  count(gain_resilience) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   gain_resilience     n  prop
##             <dbl> <int> <dbl>
## 1               4     4 22.2 
## 2               5    16 88.9 
## 3              NA     1  5.56
SKY %>%
  count(broader_perspectives) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   broader_perspectives     n  prop
##                  <dbl> <int> <dbl>
## 1                    4     4 22.2 
## 2                    5    16 88.9 
## 3                   NA     1  5.56
SKY %>%
  count(connect_with_others) %>%
  mutate(prop = 100*n/sum(n-1))
## # A tibble: 3 x 3
##   connect_with_others     n  prop
##                 <dbl> <int> <dbl>
## 1                   4     3 16.7 
## 2                   5    17 94.4 
## 3                  NA     1  5.56
SKY2 <- import(here("data", "SKY2.xlsx"), setclass = "tbl_df") 

SKY2 %>% 
  kable(caption = "The SKY Happiness Retreat impacts various domains of life") %>% 
   kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive", full_width = NULL, position = "left")) %>% 
  column_spec(6:6, bold = T, color = "#3A9E23", background = "#F8F668") %>%
   footnote(general = "The participants were asked to rate how the techniques taught in the SKY Happiness Retreat have the ability to impact different areas.",
            number = c("Numbers are in percentage"))
The SKY Happiness Retreat impacts various domains of life
:) Strongly Disagree Disagree Neutral Agree Strongly Agree
Increase my energy levels 0 0 5 15 80
Enhance my clarity of mind 0 0 0 15 85
Increase my ability to manage multiple responsibilities 0 0 0 25 75
Enhance my ability to connect to myself 0 0 0 20 80
Increase my ability to stay focused on the task at hand 0 0 5 15 80
Improve my ability to remain calm in difficult situations 0 0 5 15 80
Increase my ability to gain resilience 0 0 0 20 80
Increase my ability to gain broader perspectives when facing challenging situations 0 0 0 20 80
Increase my ability to connect with others 0 0 0 15 85
The training was good investment of time 0 0 0 14 86
Note:
The participants were asked to rate how the techniques taught in the SKY Happiness Retreat have the ability to impact different areas.
1 Numbers are in percentage
experience <- c("I thought it was positive and powerful",
                "It was very beautiful. It felt like truth",
                "Fantastic growth experience",
                "Wonderful! There were physically challenging moments while sitting for Sudarshan Kriya but I benefited a lot & have smiled more during this retreat than I have in a month",
                "I had a wonderful experience. I had been feeling very unbalanced and uncertain. I now feel much better and more centered",
                "I feel empowered and enlightened",
                "Very positive! Uplifting. Beautiful. Meaningful",
                "Great! I feel more relaxed, confident & can concentrate more on what I am doing",
                "So positive! I feel more capable of managing the things that come my way, and more open to others",
                "It was enlightening and freeing",
                "It was completely transformative. I LOVED it and felt so grateful for Sarah and Ting-fen and all their knowledge",
                "Wonderful!",
                "Kind. Open. Good experience",
                "Very positive, nurturing, and invigorating",
                "Nice. Learned so many new things",
                "Very positive and good use of time",
                "Amazing! So calming, welcoming, and educational",
                "Pretty amazing",
                "Amazing",
                "I enjoyed it",
                "It was great")

experience_df <- tibble(line = 1:21, text = experience)

experience_df <- experience_df %>%
  unnest_tokens(word, text)

data(stop_words)

experience_df <- experience_df %>%
  anti_join(stop_words)

experience_df %>%
  count(word, sort = TRUE)
## # A tibble: 54 x 2
##    word           n
##    <chr>      <int>
##  1 positive       5
##  2 feel           4
##  3 amazing        3
##  4 experience     3
##  5 wonderful      3
##  6 beautiful      2
##  7 benefited      1
##  8 calming        1
##  9 capable        1
## 10 centered       1
## # … with 44 more rows
#original
experience_df  %>%
  count(word, sort = TRUE) %>%
  filter (n > 1) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(word, n)) +
  geom_col() +
  xlab(NULL) +
  coord_flip() +
    theme_minimal(base_size = 15)

...............
## Error in eval(expr, envir, enclos): object '...............' not found
#updated
experience_df  %>%
  count(word, sort = TRUE) %>%
  filter (n > 1) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(word, n)) +
  geom_col(fill = "cornflowerblue",
           alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1),
                     limits = c(0, 5.25)) +
  xlab(NULL) +
  coord_flip() + 
  coord_flip(expand = FALSE) +
  labs(x = "Word Use",
       y = "Frequency Count",
       title = "How was the experiece?") +
    theme_minimal(base_size = 15)  + 
    theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  guides(fill = "none") 

experience <- c("I thought it was positive and powerful",
                "It was very beautiful. It felt like truth",
                "Fantastic growth experience",
                "Wonderful! There were physically challenging moments while sitting for Sudarshan Kriya but I benefited a lot & have smiled more during this retreat than I have in a month",
                "I had a wonderful experience. I had been feeling very unbalanced and uncertain. I now feel much better and more centered",
                "I feel empowered and enlightened",
                "Very positive! Uplifting. Beautiful. Meaningful",
                "Great! I feel more relaxed, confident & can concentrate more on what I am doing",
                "So positive! I feel more capable of managing the things that come my way, and more open to others",
                "It was enlightening and freeing",
                "It was completely transformative. I LOVED it and felt so grateful for Sarah and Ting-fen and all their knowledge",
                "Wonderful!",
                "Kind. Open. Good experience",
                "Very positive, nurturing, and invigorating",
                "Nice. Learned so many new things",
                "Very positive and good use of time",
                "Amazing! So calming, welcoming, and educational",
                "Pretty amazing",
                "Amazing",
                "I enjoyed it",
                "It was great")

experience_df <- tibble(line = 1:21, text = experience)

experience_df <- experience_df %>%
  unnest_tokens(word, text)

data(stop_words)

experience_df <- experience_df %>%
  anti_join(stop_words) %>% 
  filter(word != "feel" & word != "experience")

experience_df %>%
  count(word, sort = TRUE) 
## # A tibble: 52 x 2
##    word            n
##    <chr>       <int>
##  1 positive        5
##  2 amazing         3
##  3 wonderful       3
##  4 beautiful       2
##  5 benefited       1
##  6 calming         1
##  7 capable         1
##  8 centered        1
##  9 challenging     1
## 10 completely      1
## # … with 42 more rows
experience_df  %>%
  count(word, sort = TRUE) %>%
  filter (n > 1) %>%
  mutate(word = str_to_title(word),
         word = reorder(word, n)) %>%
  ggplot(aes(word, n)) +
  geom_col(fill = "cornflowerblue",
           alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1),
                     limits = c(0, 5.25)) +
  xlab(NULL) +
  coord_flip() + 
  coord_flip(expand = FALSE) +
  labs(x = "",
       y = "Word Frequency Count",
       title = "How was the experience?") +
    theme_minimal(base_size = 15)  + 
    theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  guides(fill = "none") 

 say_SKY <- c("It's a connection that connects",
          "I would say it is very much worthwhile",
          "Do it! Jump in!",
          "Come with an open mind, leave with an open heart",
          "I would highly encourage anyone to participate. I was able to be open, honest, and vulnerable about my experiences and be fully accepted",
          "It will empower you and change your life",
          "It's more than simply de-stressing. It's learning and adopting a new healthy mental lifestyle",
          "Absolutely go! The time you give to yourself to experience this retreat will help you become a better, fuller human being",
          "How much do you value allowing happiness into your life and the lives of others?",
          "This has been one of the most beautiful life experiences that I will always carry with me! SKY gives you tools to live life more fully",
          "Do it!! Just, do it!",
          "Remember the positivity in yourself and others, and spread to world",
          "It really is helpful for college student stress",
          "Go for it. Things will be better",
          "It is a good use of time",
          "This is such a valuable experience!",
          "Good stepping stones toward peace and love",
          "You should do it. Keep an open mind",
          "If you're willing to practice each day, it will help you",
          "Don't hesitate; meditate. Better get some rotalities :)")

say_df <- tibble(line = 1:20, text = say_SKY)

say_df <- say_df %>%
   unnest_tokens(bigram, text, token = "ngrams", n = 2)

 # say_df %>%
 #   count(bigram, sort = TRUE)

 bigrams_seperated <- say_df %>%
   separate(bigram, c("word1", "word2"), sep = " ")

 bigrams_filtered <- bigrams_seperated %>%
   filter(!word1 %in% stop_words$word) %>%
   filter(!word2 %in% stop_words$word)

 bigram_counts <- bigrams_filtered %>%
   unite(bigram, word1, word2, sep = " ") %>% 
   count(bigram, sort = TRUE)
 bigram_counts
## # A tibble: 16 x 2
##    bigram                  n
##    <chr>               <int>
##  1 allowing happiness      1
##  2 beautiful life          1
##  3 college student         1
##  4 de stressing            1
##  5 fuller human            1
##  6 healthy mental          1
##  7 hesitate meditate       1
##  8 highly encourage        1
##  9 life experiences        1
## 10 live life               1
## 11 mental lifestyle        1
## 12 mind leave              1
## 13 simply de               1
## 14 stepping stones         1
## 15 student stress          1
## 16 valuable experience     1
 say_df() %>%
   unnest_tokens(trigram, text, token = "ngrams", n = 2) %>%
   separate(trigram, c("word1", "word2"), sep = " ") %>%
   filter(!word1 %in% stop_words$word,
          !word2 %in% stop_words$word) %>%
   count(word1, word2, word3, sort = TRUE)
## Error in say_df(): could not find function "say_df"
 say_df() %>%
   unnest_tokens(trigram, text, token = "ngrams", n = 3) %>%
   separate(trigram, c("word1", "word2", "word3"), sep = " ") %>%
   filter(!word1 %in% stop_words$word,
          !word2 %in% stop_words$word,
          !word3 %in% stop_words$word) %>%
   count(word1, word2, word3, sort = TRUE)
## Error in say_df(): could not find function "say_df"
ggplot(aes(word, n)) +
  geom_col(fill = "#CCFB5D",
           alpha = 0.7) +
  scale_y_continuous(breaks = seq(0, 11, by = 1),
                     limits = c(0, 5.25)) +
  xlab(NULL) +
  coord_flip() + 
  coord_flip(expand = FALSE) +
  labs(x = "Phrase Use",
       y = "Frequency Count",
       title = "How would you say to someone considering the Retreat?") +
    theme_minimal(base_size = 15)  + 
    theme_minimal(base_size = 15)  + 
  theme(panel.grid.minor = element_line(linetype = "blank")) +
  guides(fill = "none") 
## Error: `data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class uneval
## Did you accidentally pass `aes()` to the `data` argument?